<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增维保报告书联系单')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-sheet-add">
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">维保报告书 ：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input id="mMreport" name="file" multiple class="form-control" type="file">-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">维保联系单：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input id="mMcontactSheet" name="file1" multiple class="form-control" type="file">-->
<!--                </div>-->
<!--            </div>-->
            <div class="form-group">    
                <label class="col-sm-3 control-label">维保费申请支付联系单：</label>
                <div class="col-sm-8">
                    <input id="mMforPayment" name="file2" multiple class="form-control" type="file">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">排查问题联系单：</label>
                <div class="col-sm-8">
                    <input id="mCheckProblem" name="file3" multiple class="form-control" type="file">
                </div>
            </div>
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">创建时间：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <div class="input-group date">-->
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
<!--                        <input name="mTime" class="form-control" placeholder="yyyy-MM-dd" type="text">-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="form-group">    -->
<!--                <label class="col-sm-3 control-label">外键id：</label>-->
<!--                <div class="col-sm-8">-->
<!--                    <input name="mtId" class="form-control" type="text">-->
<!--                </div>-->
<!--            </div>-->
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script type="text/javascript">
        var prefix = ctx + "ruoyi/sheet1"
        $("#form-sheet-add").validate({
            focusCleanup: true
        });
        function submitHandler() {
            if ($.validate.form()) {
                uploadFile();
            }
        }

        function uploadFile() {
            var formData = new FormData();
            // if ($('#mMreport')[0].files[0] == null) {
            //     $.modal.alertWarning("请先选择文件路径");
            //     return false;
            // }
            // if($('#mMcontactSheet')[0].files[0] == null) {
            //     $.modal.alertWarning("请先选择文件路径");
            //     return false;
            // }
            if($('#mMforPayment')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            if($('#mCheckProblem')[0].files[0] == null) {
                $.modal.alertWarning("请先选择文件路径");
                return false;
            }
            // formData.append('file', $('#mMreport')[0].files[0]);
            // formData.append('file1', $('#mMcontactSheet')[0].files[0]);
            formData.append('file2', $('#mMforPayment')[0].files[0]);
            formData.append('file3', $('#mCheckProblem')[0].files[0]);
            $.ajax({
                url: prefix + "/add",
                type: 'post',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                dataType: "json",
                success: function(result) {
                    $.operate.successCallback(result);
                }
            });
            formData = new FormData();
        }
        // function submitHandler() {
        //     if ($.validate.form()) {
        //         $.operate.save(prefix + "/add", $('#form-sheet-add').serialize());
        //     }
        // }

        $("input[name='mTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
    </script>
</body>
</html>